package com.camemax.operators;

import com.camemax.pojo.AdvertisementView;
import org.apache.flink.api.common.functions.AggregateFunction;
/*
* Flink AggregateFunction 实现数据流的累加操作
* */
public class AdAggregateFunction implements AggregateFunction<AdvertisementView, Long, Long> {
    @Override
    public Long createAccumulator() {
        return 0L;
    }

    @Override
    public Long add(AdvertisementView value, Long accumulator) {
        return accumulator+1;
    }

    @Override
    public Long getResult(Long accumulator) {
        return accumulator;
    }

    @Override
    public Long merge(Long a, Long b) {
        return a + b;
    }
}
